package com.example.demo.client.vm.cssmqry.resource;

import com.ffcs.oss.common.utils.tree.TreeFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author linxiao
 * @Date 2020/06/25  17:14
 */
@ApiModel
public class BasicResourceVm implements TreeFormat<BasicResourceVm, String>, Serializable {
    private static final long serialVersionUID = 3877320881308914637L;
    @ApiModelProperty("资源主键ID")
    private String id;
    @ApiModelProperty("资源名称")
    private String name;
    @ApiModelProperty("资源父ID")
    private String parentId;
    @ApiModelProperty("是否选中:1-选中(其他都代表未选中)")
    private Short checked;
    @ApiModelProperty("子元素")
    private List<BasicResourceVm> children;

    @Override
    public String getTreeFormatId() {
        return id;
    }

    @Override
    public String getParentTreeFormatId() {
        return parentId;
    }

    @Override
    public void addChildren(BasicResourceVm child) {
        if (children == null) {
            this.children = new ArrayList<>();
        }
        children.add(child);
    }

    public Short getChecked() {
        return checked;
    }

    public void setChecked(Short checked) {
        this.checked = checked;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public List<BasicResourceVm> getChildren() {
        return children;
    }

    public void setChildren(List<BasicResourceVm> children) {
        this.children = children;
    }

    @Override
    public String toString() {
        return "BasicResourceVm{" +
            "id='" + id + '\'' +
            ", name='" + name + '\'' +
            ", parentId='" + parentId + '\'' +
            ", checked=" + checked +
            ", children=" + children +
            '}';
    }
}
